package com.hgnu.dorm.mapper;

import com.hgnu.dorm.domain.po.RolePermission;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface RolePermissionMapper {

    @Select("SELECT * FROM dorm.role_permission where role_id = #{roleId}")
    List<RolePermission> findAllByRoleId(Long roleId);

    @Insert("INSERT INTO dorm.role_permission(role_id, permission_id) VALUES (#{roleId}, #{permissionId})")
    void insert(RolePermission rolePermission);

    @Delete("DELETE FROM dorm.role_permission WHERE role_id = #{roleId} AND permission_id = #{permissionId}")
    void deleteByRoleIdAndPermissionId(@Param("roleId") Long roleId, @Param("permissionId") Long permissionId);
}
